from fastapi import APIRouter
from src.db.db_models import *
from src.models import check_models
from src.sevices import SCORE_SERVICES

score_router = APIRouter()


# 增加学生成绩
@score_router.post("/score_add", summary="增加学生成绩")
async def score_add(add_score: check_models.Add_score):
    return await SCORE_SERVICES.score_add_serives(add_score)


# 查询所有学生
@score_router.get("/all_score", summary="查询所有学生成绩")
async def get_all_score():
    return await Score.all().values()


# 查询单个学生
@score_router.get("/one_student/{s_id}", summary="查询单个学生成绩")
async def get_one_score(s_id: int):
    return await SCORE_SERVICES.select_one_student(s_id)


# 更新学生成绩
@score_router.put("/{s_id}", response_model=dict, summary="更新学生成绩")
async def score_put(s_id: int, student_score: check_models.Student_score_put):
    return await SCORE_SERVICES.score_put_services(s_id, student_score)


# 成绩的删除
@score_router.delete("/delete", summary="删除学生成绩")
async def delete_score(score_model: check_models.Student_score_delete):
    return await SCORE_SERVICES.delete_score_services(score_model)
